<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/15
 * Time: 16:14
 */

namespace Common\Common;


class Download{


    public function load($file){


        if (is_array($file)) {

            $file_name = explode('/', $file['file_url']);

            header('Content-type:' . $file['file_type']);
            header('Accept-Panges:bytes');
            header('Accept-length', $file['file_size']);
            header('Content-Disposition:attachment;filename=' . urldecode(array_pop($file_name)));

            ob_clean();
            flush();

            echo file_get_contents(iconv('utf-8', 'gbk', $file['file_url']));


        }
    }


    function down($file_resource,$size){
        $buffer = 1024;
        $output=0;
        while (!(feof($file_resource) && ($output<$size))){

            $file = fread($file_resource,$output);

                $output +=$buffer;

                echo $file;
        }
            return;
    }




}